// redlockConfig.js
const { createClient } = require('ioredis');
const Redlock = require('redlock');

// Create a Redis client
const redisClient = createClient({
  url: 'redis://localhost:6379', // Ensure this matches your Redis server configuration
  password: '123456' // Use your actual Redis password if set
});

// Create a Redlock instance
const redlock = new Redlock(
  [redisClient], // Pass an array of Redis clients
  {
    retryCount: 10,    // Number of retries
    retryDelay: 200,   // Time between retries in ms
    retryJitter: 200   // Randomize retry delay to avoid stampeding
  }
);

module.exports = redlock;